<?php
use \Model\Target;
use \Model\Msg;
use \Model\Account;
class Controller_Msg extends Controller_Weibo{
	function action_portal() {
		$target = Target::get_account(Session::get('user_id', 0), 100000, 0);
		foreach ($target as $k => $v) {
			$idstr[] = $v['idstr'];
		}
		$account = Account::get_account(Session::get('user_id', 0));
		$page_config = Config::get('pagination.msg', array());
		$page_config['total_items'] = Msg::get_cnt($idstr);
		$page = Uri::segment(2, 1);
		Config::set('pagination', $page_config);
		Pagination::$current_page = $page;
		$msg = Msg::get($idstr,  Pagination::$per_page, Pagination::$per_page * (Pagination::$current_page - 1));
		$page_links = Pagination::create_links();
		$this->data['content'] = View::forge('msg/content', array('msg' => $msg, 'page_links' => $page_links, 'account' => $account));
		return Response::forge(View::forge('layout', $this->data));
	}
}
